package com.supermali.entity.npc.monistor.helpful;

import com.supermali.behavior.Dxy;
import com.supermali.behavior.util.Up16Px;
import com.supermali.creater.MapCreater;
import com.supermali.creater.img.ImgHelper;
import com.supermali.creater.img.ImgKey;
import com.supermali.creater.img.ImgLoader;
import com.supermali.entity.npc.person.Person;

import java.awt.image.BufferedImage;

public class GrowthMushroom extends HelpfulAbstract {

    // 上移16px
    Up16Px up16Px;

    public GrowthMushroom(Double x, Double y, MapCreater mapCreater) {
        super(x, y, mapCreater);
    }

    @Override
    public void helpPerson() {
        MapCreater mapCreater = getMapCreater();
        Person person = mapCreater.getPerson();
        // 生长蘑菇 状态设置为大人物  同时 蘑菇消失
        if(person.getBigStatus()== Person.BigStatus.SMALL) {
            person.setBigStatus(Person.BigStatus.BIG);
        }
    }


    @Override
    public void proccessData(long delta) {
        if(!up16Px.isOver()){
            Dxy dxy = up16Px.up(delta);
            this.setY(getY()+dxy.getDy());
        }else {
            getGravity().autoDown();
            if(!getMonitorMove().isOver()) {
                getMonitorMove().move(delta);
            }
        }
    }

    @Override
    public void init() {
        ImgHelper imgHelper = ImgLoader.getImgHelper(ImgKey.Monistor.GROWTH_MUSHROOM);
        BufferedImage select = imgHelper.select(0);
        this.setBufferedImage(select);
        this.up16Px = new Up16Px();
        this.up16Px.up(0);
    }
}
